package zjs.dc.controller;

import org.apache.spark.sql.SparkSession;

/**
 * @Class:
 * @Author: kongcb
 * @Description: TODO
 * @Date: 2021/12/30 14:04
 */
public class TIntellectualPropertyCount {
    public static void main(String[] args) {
        SparkSession spark = SparkSession.builder().appName("t_intellectual_property_count").enableHiveSupport().getOrCreate();
        spark.sparkContext().setLogLevel("ERROR");
        //企业工商数据t_eci_company
        spark.sql("select company_id,company_name from a_dc_ep_dwi.t_tm").createOrReplaceTempView("tm");
        //企业工商数据t_eci_partner
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_patent by company_id").createOrReplaceTempView("patent");
        //企业工商数据t_eci_employee
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_copyrights_copyright group by company_id").createOrReplaceTempView("copyrights_copyright");
        //企业工商数据t_eci_branch
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_copyrights_softwarecopyright group by company_id").createOrReplaceTempView("copyrights_softwarecopyright");
        //企业工商数据t_eci_change
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_website group by company_id").createOrReplaceTempView("website");


        spark.sql("insert overwrite table a_dc_ep_incr.t_manage_count select a.company_id,a.company_name,b.cn,c.cn,'' as n1,d.cn,e.cn,f.cn,g.cn from eci_company a " +
                "left join tm b on a.company_id = b.company_id " +
                "left join patent c on a.company_id = c.company_id " +
                "left join copyrights_copyright d on a.company_id = d.company_id " +
                "left join copyrights_softwarecopyright e on a.company_id = e.company_id " +
                "left join website f on a.company_id = f.company_id " +
                "left join website g on a.company_id = g.company_id ");
        spark.stop();
    }

}
